package com.android.lovely.ui.viewmodel

import androidx.lifecycle.viewModelScope
import androidx.paging.Pager
import androidx.paging.PagingConfig
import com.android.lovely.api.service.botService
import com.android.lovely.data.HomeListData
import com.android.lovely.data.HomeTabData
import com.android.lovely.framework.BaseLoadViewModel
import com.android.lovely.framework.BasePageSource
import com.android.lovely.framework.BaseViewModel
import com.android.lovely.framework.doContinuousOperation
import com.kotlin.extensions.coroutine.CoroutineExt.launchSafety
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow

/**
 *
 * @author why
 * @date 2025/3/10 15:09
 */
class HomeListViewModel: BaseLoadViewModel<HomeListData>() {

    var tab: Int? = null
    override suspend fun requestApi(page: Int, loadSize: Int): List<HomeListData> {
        return botService.getHomeList(
            mapOf(
                "r_id" to tab, "page" to page, "size" to loadSize, "condition" to 0
            )
        ).getOrDefault("list", emptyList()).onEach {
            it.insertOrUpdateProfile()
        }
    }
}